package model;

import java.util.Vector;

public class proto_battler {
	private int index = 0;
	private int maxIndex = 0;
	int hp = 0;
	int maxhp = 0;
	int at = 0;
	int dam = 0;
	Vector<proto_card> deck = new Vector<proto_card>();
	String name = "";
	int skill = 0;
	char posElem = 0;
	char negElem = 0;
	public void prepare(boolean recover) {
		if (proto_main.DEBUG && deck.size() < 1) {
			System.out.println("[Error]In proto_battler:prepare.\ndeck size is less than 1.");
			System.exit(0);
		}
		index = 0;
		maxIndex = deck.size();
		maxhp = 0;
		for (int i=0;i < maxIndex;i++) {
			maxhp += deck.get(i).hp;
		}
		if (recover) {
			hp = maxhp;
		}
		try {
			at = deck.get(index).at();
		} catch (Exception e) {
			at = 0;
		}
	}
	public void apply_buff() {
		// TODO Auto-generated method stub
		
	}
	public char next_action() {
		index = (index+1)%maxIndex;
		at = deck.get(index).at();
		return 0;
	}
	public boolean is_dead() {
		return (hp < 1);
	}
	public int at() {
		return at;
	}
	public void damage(int dam) {
		this.dam = dam;
	}
	public void apply_damage() {
		hp -= dam;
		if (hp < 0) {
			hp = 0;
		} else if (hp > maxhp) {
			hp = maxhp;
		}
		dam = 0;
	}
	
}
